<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::view('/', 'welcome');
//微信登陆请求,入口部分
Route::group(['middleware' => ['simulatedWechatUser', 'wechat.oauth']], function () {
    //公众号内直接点击进入（需要调起扫码）（返回front.shopping页面）
    Route::get('/shopping/direct', 'PagesController@directShop');
    //扫码机器码购买（显示商品列表）（返回front.shopping页面）
    Route::get('/shopping/machines/{machine_uuid}', 'PagesController@machineShop');
    //直接下订单（机器操作过后，直接扫码下单）（返回front.shopping页面）
    Route::get('/shopping/product/{machine_uuid}/{product_uuid}', 'PagesController@productShop');
    //个人中心入口（返回front.personal页面）
    Route::get('/personal', 'PagesController@personal');
});

Route::group(['middleware' => 'auth', 'prefix' => 'api/v1', 'namespace' => 'Api'], function () {
    //获取用户部分
    Route::group(['prefix' => 'profile'], function () {
        Route::get('/', 'UserController@getProfile');
        Route::get('/point_logs', 'UserController@getPointLogs');
        Route::get('/point_bag_logs', 'UserController@getPointBagLogs');
        Route::get('/coupons', 'UserController@getCoupons');
        Route::get('/orders', 'UserController@getOrders');
    });

    //获取当前机器详情,和当前商品
    Route::get('/current/machine', 'MachineController@getCurrentMachine');
    Route::get('/current/product', 'ProductController@getCurrentProduct');


    //绑定手机号
    Route::post('/bind-sms', 'PhoneVerificationsController@send');
    Route::post('/bind-phone-number-by-sms', 'UserController@bindPhoneNumberBySms');

    //获取机器下的产品
    Route::get('/machines/{machine}/products', 'MachineController@getProductsByMachine');

    //微信内支付，获取预支付订单号
    Route::post('get-order-prepay-id', 'PayController@getOrderPerpayId');

    //成长咖啡满一杯兑换
    Route::get('exchange-growing-coffee', 'GrowingCoffeeController@exchange');

    //积分福袋部分
    Route::get('buy-point-bag/{point_bag}', 'PointBagController@buyPointBag');

    //免费码兑换免费咖啡券
    Route::get('free-coupon-by-code', 'CouponController@freeCouponByCode');
    Route::post('get-free-code', 'CouponController@freeCouponByCode');

    //团体申请
    Route::post('team_apply', 'TeamController@apply');

});

Route::group(['prefix' => 'api/v1', 'namespace' => 'Api'], function () {
    //获取轮播图数据
    Route::get('sliders', 'SliderController@getAll');
    //获取分类数据
    Route::get('categories', 'CategoryController@getAll');
    //获取所有商品数据
    Route::get('products', 'ProductController@getAll');
    //获取分类下所有商品
    Route::get('category/{category}/products', 'CategoryController@getProducts');
    //接收支付回调
    Route::post('pay-notify', 'PayController@payNotify');
});

Route::group(['middleware' => 'admin', 'prefix' => 'api/v1', 'namespace' => 'Api'], function () {
    //免费码兑换免费咖啡券
    Route::get('free-coupon-by-code', 'CouponController@freeCouponByCode');
    Route::post('get-free-code', 'CouponController@freeCouponByCode');
    Route::post('get-all-free-code', 'CouponController@freeAllCouponByCode');
});



